-
Notifications
You must be signed in to change notification settings - Fork 5
feat: initial streams support and convert to I/O module #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Need to rename this package to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
@robik please see latest one (but disregard StreamMangaer, it needs some work) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 💪
I just left some questions and a few nitpicks
|
||
async write(chunk: ArrayBuffer) { | ||
if (!outputStream.hasSpaceAvailable()) { | ||
throw new Error('No space available in output stream') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Q] Do we really have to throw here? Cannot we apply backpressure or wait for the space to become available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds like we should handle this! Not sure how easy/hard would it be!
|
||
export interface InputStream extends HybridObject<{ ios: 'swift' }> { | ||
hasBytesAvailable(): boolean | ||
read(buffer: ArrayBuffer, maxLength: number): number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] This would be a pulling API, right? Maybe we can return a Promise
here to get notified that data is available, or a callback? wdyt?
[nit] How do you distinguish EOF and empty buffer (when used in a non-blocking way)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good questions. Please check https://developer.apple.com/documentation/foundation/inputstream and let me know the answer! 🥲
packages/react-native-fast-ws/ios/HybridPassThroughStream.swift
Outdated
Show resolved
Hide resolved
Thank you @mani3xis for your review. I have addressed some of your comments (answered & resolved), please feel free to unresolve ro follow-up if another issue persist. The remaining comments are great next-steps and we should convert them to issues and just get done! NOTE: This PR does not implement Android, so after merging it will be temporarily broken which is fine 🤣 |
Cleaned up history of the PR for rebase/merge instead of a squash. |
This is just an experiment and a bit naive implementation. Needs some fine tuning, but it's a good proof of concept of a readable stream (that is coming from the native side).
What it does?
This API is split across two parts: